<?php
declare (strict_types=1);

namespace app\controller;

use app\BaseController;
use think\exception\ValidateException;

class Validate extends BaseController
{
    public function index()
    {
        try {
            $this->validate([
                'name' => 'thinkphp',
                'email' => 'thinkphp@qq.com',
            ], 'app\index\validate\User');
        } catch (ValidateException $e) {
            // 验证失败 输出错误信息
            dump($e->getError());
        }
    }
}